package org.trajectory.plugin;

import java.io.InputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.pentaho.platform.api.engine.IFileInfo;
import org.pentaho.platform.api.engine.ISolutionFile;
import org.pentaho.platform.api.engine.SolutionFileMetaAdapter;
import org.pentaho.platform.engine.core.solution.FileInfo;
import org.trajectory.plugin.util.PluginConfig;
/**
 * 
 * @author Administrator
 *
 */
public class TrajectoryContentTypeMetaProvider extends SolutionFileMetaAdapter {

    private static final Log LOG = LogFactory.getLog(TrajectoryContentTypeMetaProvider.class);

    public TrajectoryContentTypeMetaProvider() {};
    
    public IFileInfo getFileInfo(ISolutionFile solutionFile, InputStream in) {
        try {
            String title = solutionFile.getFileName();
            if (title != null && title.endsWith(PluginConfig.PLUGIN_SUFFIX)) {
            	title = title.substring(0,title.indexOf(PluginConfig.PLUGIN_SUFFIX));
            }

            IFileInfo info = new FileInfo();
            info.setAuthor("Cloud Lau");
            info.setDescription("Trajectory");
            info.setIcon(PluginConfig.ICON);
            info.setTitle(title);
            return info;

        } catch (Exception e) {
            LOG.error(getClass().toString(), e);
        }
        return null;
    }
}
